import 'package:flutter/material.dart';
import './tabs/diary.dart';
import './tabs/home.dart';
import './tabs/person.dart';
import './login.dart';

class tabber extends StatefulWidget {
  tabber({Key? key}) : super(key: key);
  @override
  State<tabber> createState() => _tabberState();
}

class _tabberState extends State<tabber> {
  int _currentIndex = 0; //当前的页面
  final List<Widget> _pages = [
    home(),
    diary(),
    person(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: _pages[_currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          onTap: (value) => {
            setState(() => {_currentIndex = value}),
          },
          currentIndex: _currentIndex,
          selectedItemColor: Colors.indigoAccent,
          // unselectedItemColor: Colors.black12,
          items: const [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
            BottomNavigationBarItem(icon: Icon(Icons.book), label: "1122"),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: "aaa"),
          ],
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        floatingActionButton: Container(
          padding: const EdgeInsets.all(5),
          margin: const EdgeInsets.only(top: 10),
          height: 60,
          width: 60,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(30),
          ),
          child: FloatingActionButton(
            child: Icon(Icons.add),
            elevation: 10,
            backgroundColor:
                _currentIndex == 1 ? Colors.deepOrange : Colors.blueAccent,
            splashColor: Colors.deepOrange,
            onPressed: _goPage,
          ),
        ));
  }

  void _goPage() {
    setState(() => {_currentIndex = 1});
  }
}
